#include "stdafx.h"
#include <serialization/ioParamStructs.h>
#include <serialization/serialization.h>
#include <winsock/winsock_stub.h>

void getsockname_stub (
    __in  std::vector<char>& in_buf,
    __out std::vector<char>& out_buf
    )
{
//RECEIVE()
    Deserialize deserialize (in_buf);
    getsockname_in_inout getsocknameIN;
    deserialize(getsocknameIN);

    struct sockaddr addr;
    int ret = getsockname(getsocknameIN.s_, &addr, getsocknameIN.addrlen_);
//SEND
    getsockname_out_inout getsocknameOUT(
        &addr, getsocknameIN.addrlen_, (ret == 0) ? 0 : WSAGetLastError());
    
    Serialize(deserialize.get_header(), getsocknameOUT, out_buf);
}
